package cn.sieis.service.contest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.sieis.dao.ContestMapper;
import cn.sieis.pojo.Contest;
@Service
public class ContestServiceImpl implements ContestService{
	
	@Autowired
	private ContestMapper contestMapper;

	@Override
	public List<Contest> getContestList(String queryConName,Integer queryConApplication, Integer queryConLevel, Integer currentPageNo,
			Integer pageSize) throws Exception {
		// TODO Auto-generated method stub
		currentPageNo = (currentPageNo-1)*pageSize;
		return contestMapper.getContestList(queryConName,queryConApplication, queryConLevel, currentPageNo, pageSize);
	}

	@Override
	public int getContestCount(String queryConName,Integer queryConApplication, Integer queryConLevel) throws Exception {
		// TODO Auto-generated method stub
		return contestMapper.getContestCount(queryConName,queryConApplication, queryConLevel);
	}

	@Override
	public boolean addContest(Contest contest) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		if(contestMapper.addContest(contest)>0){
			flag=true;
		}
		return flag;
	}

	@Override
	public boolean modify(Contest contest) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		if(contestMapper.modify(contest)>0){
			flag=true;
		}
		return flag;
	}

	@Override
	public Contest getContestById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return contestMapper.getContestById(id);
	}

	@Override
	public boolean deleteContestById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		int i=contestMapper.deleteContestById(id);
		if(i>0){
			flag=true;
		}else{
			flag=false;
		}
		return flag;
	}

	@Override
	public List<Contest> getConList(String queryConName,Integer queryConApplication, Integer queryConLevel) throws Exception {
		// TODO Auto-generated method stub
		return contestMapper.getConList(queryConName,queryConApplication, queryConLevel);
	}

	@Override
	public List<Contest> getConConList() throws Exception {
		// TODO Auto-generated method stub
		return contestMapper.getConConList();
	}
	
	@Override
	public List<Contest> getContestListFr(String conName, Integer conLevel) {
		// TODO Auto-generated method stub
		return contestMapper.getContestListFr(conName, conLevel);
	}

}
